package edu.byu.intex2.data.bo;

/**
 * @author Jason Whiting
 */
public abstract class BusinessObject
{
    boolean objectAlreadyInDB = false;
    protected boolean dirty = true;
    protected String id = null;

    /**
     * Creates a new instance of BusinessObject
     * @param id
     */
    public BusinessObject(String id)
    {
        this.id = id;
    }//constructor

    /** Returns the guid of this BO */
    public String getId()
    {
        return id;
    }//getID

    /** Set the ID of the business object */
    public void setId(String id)
    {
        this.id = id;
    }

    /** Returns whether the object is in the DB or not */
    public boolean isObjectAlreadyInDB()
    {
        return objectAlreadyInDB;
    }//isObjectAlreadyInDB

    /**
     * Sets whether the object is already in the DB.  This method
     * is called ONLY from the DAO responsible for this object.
     */
    public void setObjectAlreadyInDB(boolean objectAlreadyInDB)
    {
        this.objectAlreadyInDB = objectAlreadyInDB;
    }//setObjectAlreadyInDB

    /** Returns whether the object needs saving or not */
    public boolean isDirty()
    {
        return dirty;
    }//isDirty

    /**
     * Sets whether the object needs saving or not.  This method
     * is called ONLY from the DAO responsible for this object.
     */
    public void setDirty(boolean dirty)
    {
        this.dirty = dirty;
    }//setDirty

    /** Just a convenience method that calls setDirty(true) */
    public void setDirty()
    {
        setDirty(true);
    }//setDirty
}//class
